package com.lvmama.pangolin.proxyip.biz;



import com.lvmama.pangolin.entity.IP;
import com.lvmama.pangolin.proxyip.inter.ProxyIPProcesser;
import com.lvmama.pangolin.proxyip.inter.TokenProxyIPProcesser;

import java.util.List;

/**
 * Created by NUCTONY on 2016/4/3.
 */
public abstract class AbstractCollectProxyIP {


    private String url;
    private boolean pageable = true;
    private String urlSuffix = "";
    private String userAgent;
    private String referrer;
    private String host;
    private int startPage = 1;
    private int endPage = 1;
    private int requestNum;
    protected final static String defaultUserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36";
    protected final static int defaultRequestNum = 3;

    protected AbstractCollectProxyIP() {

    }

    protected AbstractCollectProxyIP(String url, String urlSuffix, String userAgent, String referrer, String host, int startPage, int endPage, int requestNum) {
        this.url = url;
        if (urlSuffix != null)
            this.urlSuffix = urlSuffix;
        this.userAgent = userAgent;
        this.referrer = referrer;
        this.host = host;
        this.startPage = startPage;
        this.endPage = endPage;
        this.requestNum = requestNum;
    }

    protected AbstractCollectProxyIP(String url, String urlSuffix, String userAgent, String referrer, String host, int startPage, int endPage, int requestNum, boolean pageable) {
        this.url = url;
        if (urlSuffix != null)
            this.urlSuffix = urlSuffix;
        this.userAgent = userAgent;
        this.referrer = referrer;
        this.host = host;
        this.startPage = startPage;
        this.endPage = endPage;
        this.requestNum = requestNum;
        this.pageable = pageable;
    }

    public abstract List<IP> doRequest(ProxyIPProcesser processer);

    public List<IP> doRequest(TokenProxyIPProcesser processer) {
        return null;
    }

    public String getUrl() {
        return url;
    }


    public String getUserAgent() {
        return userAgent;
    }


    public String getReferrer() {
        return referrer;
    }


    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getStartPage() {
        return startPage;
    }


    public int getEndPage() {
        return endPage;
    }


    public int getRequestNum() {
        return requestNum;
    }

    public String getUrlSuffix() {
        return urlSuffix;
    }

    public boolean isPageable() {
        return pageable;
    }

    public void setPageable(boolean pageable) {
        this.pageable = pageable;
    }
}
